﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace CPPEI.Coolzon.UI.XProperty.Converters
{
    /*
     * string 
     * 和
     * <String Value="CDPDB"/>
     * 之间相互转换
     * */
    public class XStringConverter : IPropertyValueConverter
    {
        public object Convert(ConvertContext context, Metadata.ValueNode valueNode)
        {
            return valueNode.Attributes["Value"];
        }

        public Metadata.ValueNode ConvertBack(ConvertContext context, object value)
        {
            Metadata.ValueNode valueNode = new Metadata.ValueNode("String");
            valueNode.Attributes = new Dictionary<string, string>();
            valueNode.Attributes.Add("Value", System.Convert.ToString(value));
            return valueNode;
        }
    }
}
